<html>
<!-- $LastChangedDate: 2009-11-22 22:39:11 -0500 (Sun, 22 Nov 2009) $ -->
<!-- Copyright (C) 2004,2009 Jim Brooks http://www.palomino3d.org -->
<head>
<title>Palomino - Physics Module</title>
<link rel='stylesheet' type='text/css' href='docs.css'>
<link rel='icon' type='image/png' href='images/favicon.png'/>
</head>
<body>

<!-- ----------------------------------------------------------------------- -->
<h1>Palomino - Physics Module</h1>
<p>
&copy;2004,2009&nbsp;&nbsp;Jim E. Brooks
&nbsp;&nbsp;<a href='http://www.palomino3d.org'>http://www.palomino3d.org</a>
</p>
<hr>
<ul>
  <li><a href='index.html'>Index</a></li>
  <li><a href='#Overview'>Overview</a></li>
  <li><a href='#Forces'>Forces</a></li>
      <ul>
        <li><a href='#Contact Force'>Contact Force</a></li>
        <li><a href='module_collision.html#Safe Contact'>Safe Contact</a></li>
      </ul>
  <li><a href='#CraftPhysics'>CraftPhysics</a></li>
      <ul>
        <li><a href='module_control.html#Control of Craft'>Control of Craft</a></li>
        <li><a href='#Coordinated Turn'>Coordinated Turn</a></li>
        <li><a href='#Landing'>Landing</a></li>
      </ul>
</ul>

<!-- ----------------------------------------------------------------------- -->
<hr>
<a name='Overview'></a>
<h2>Overview</h2>
<p><!--date-->[2008/01]</p>
<p>
Physics computations are done in terms of SI units (metric).
The physics module consults <a href='module_world.html#Geo'>Geo</a>
to convert between physical metrics and graphical coordinates.
</p>

<!-- ----------------------------------------------------------------------- -->
<hr>
<a name='Forces'></a>
<h2>Forces</h2>
<p><!--date-->[2008/02]</p>
<h3>Overview</h3>
<p>
Net force is the sum of vector addition.
However, not all physical forces are simulated,
and physical forces are computed in a particular order.
</p>
<a name='Contact Force'></a>
<h3>Contact Force</h3>
<p>
Contact force is not simply negative weight.
Rather, it's the negative of <i>net</i> weight.
</p>
<p>
Imagine a propeller aircraft on a runway rotated upward slightly.
The vertical coordinate of engine thrust counteracts its weight.
Contact force is the sum of absolute weight minus the engine's vertical force.
</p>
<p>
<a href='module_world.html#Geo'>Geo</a> has a registered list of <a href='module_world.html#RigidBody'>RigidBody</a> objects.
</p>

<!-- ----------------------------------------------------------------------- -->
<hr>
<a name='CraftPhysics'></a>
<h2>CraftPhysics</h2>
<p><!--date-->[2008/02]</p>
<p>
CraftPhysics is specialized for aircraft.
</p>
<ul>
  <li>Simulates the 4 fundamental forces: thrust/drag/weight/lift.</li>
  <li>Physics computations are done in terms of physical metrics (SI units)
      and converted to graphical coordinates.</li>
  <li>Speed gradually increases from thrust.</li>
  <li>Drag increases as speed increases, opposite to direction of velocity, and will balance thrust, thereby limiting speed.</li>
</ul>
<p>
A Craft (or derivative), a CraftPhysics, and CraftSpecs will be bound together at run-time.
For example, P51Aircraft has a CraftPhysics object that stores and computes physical state
as determined by data in a CraftSpecs which defines the characteristics of a P-51D Mustang.
</p>
<p>
The CraftPhysics class is written in terms of the Craft interface
and can manipulate (move) a Craft object.
Craft is a derivative of Dyna and Dyna in turn is derived from Object.
A reason is that Craft defines the axises of the local coordinate space
which CraftPhysics needs access to.
For example, the thrust vector correlates to a Craft's Z axis.
CraftPhysics will call Craft::Translate(axis,step) to move along an axis.
</p>
<p>
The animation convention is for a 3D Object to register a timer-tick handler.
When a tick arrives, a Craft will defer its animation to its CraftPhysics member.
CraftPhysics computes a net vector offset in World Space then
CraftPhysics changes the position of a Craft (moves it) in terms of the Craft interface.
</p>
<pre>
tick event <img src='images/arrowGreen.gif' hspace='8'> Dyna::Tick() <img src='images/arrowGreen.gif' hspace='8'> CraftPhysics::MoveObject()
</pre>

<!-- ----------------------------------------------------------------------- -->
<hr>
<a name='Coordinated Turn'></a>
<h2>Coordinated Turn</h2>
<p><!--date-->[2008/01]</p>
<p>
Coordinated turn means coordinated control of pitch/roll/yaw during a normal banked turn.
Controlling only pitch and roll isn't sufficient.
What would happen (in the sim) without yaw is that the craft would pitch up too much.
Yawing in the direction of the turn is necessary to keep the nose level during the turn.
</p>
<p>
The program can help the player do a coordinated turn by automatically controlling yaw.
The reasons are that most joysticks lack a third axis to control yaw,
and some users may have difficulty controlling 3 axises at a time.
</p>
<p>
For an automatic coordinated turn, the degree of yaw is approximately
the same as the degree of pitch but in the direction of the turn.
The difficulty in implementing this is <i>detecting</i>
when the player wants to do a <i>normal banked turn</i>.
For example, the player would be diving, then does a roll followed by a pitch.
The roll/pitch sequence would be a false indicator since the player is really
changing the direction of the dive, not doing a banked turn.
</p>

<!-- ----------------------------------------------------------------------- -->
<hr>
<a name='Landing'></a>
<h2>Landing</h2>
<p><!--date-->[2008/03]</p>
<p>
Behavior of landing is more user-friendly than realistic.
When the player touches the runway, the program grabs control of the player's Aircraft.
It will automatically stop downward velocity and pitch up/down in to level the Aircraft.
The player will still need to apply brakes.
</p>

<!-- ********************************* END ********************************* -->
<hr>
<p align='center'>
<font size='-2'>
<!-- hhmts start -->
Last modified: Sun Nov 22 21:23:00 CST 2009
<!-- hhmts end -->
</font>
</p>

</body>
</html>
